package org.yray.netty.v5;

import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.apache.log4j.Logger;


public class ByteHandler  extends SimpleChannelInboundHandler {
    /**
     当通道被调用，执行方法(拿到数据)
     */
    private static Logger log = Logger.getLogger(ByteHandler.class);
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        super.channelRead(ctx, msg);
        String value = (String) msg;
        System.out.println("服务器端收到客户端msg:"+value);
        //回复客户端
        ctx.writeAndFlush("收到msg"+value);
    }

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Object o) throws Exception {

    }

    //@Override
    protected void messageReceived(ChannelHandlerContext channelHandlerContext, Object o) throws Exception {

    }


}
